package cn.fws.meap.community.web;

import java.util.List;

import cn.fws.meap.utils.logBug.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.fws.meap.community.entity.Creation;
import cn.fws.meap.community.service.ICreationService;
import cn.fws.meap.community.vo.CreationDetaileVo;
import cn.fws.framework.web.contoller.BaseController;
import cn.fws.framework.web.page.PagingResult;
import cn.fws.framework.web.contoller.JsonResponse;

/**
 * 创作记录 信息操作处理
 * 
 * @author chenkh
 * @date 2019-03-07
 */
@RestController
@RequestMapping("/meap/creation")
@Api(tags = "创作记录 信息操作处理")
public class CreationController extends BaseController{

	@Autowired
	private ICreationService creationService;
	
	/**
	 * 查询创作记录列表
	 */
	//@RequiresPermissions("meap:creation:list")
	@ApiOperation(value = "查询创作记录列表")
	@PostMapping("/list")
	public PagingResult<Creation> list(Creation creation){
		startPage();
        List<Creation> list = creationService.selectList(creation);
		return getPagingResult(list);
	}

	/**
	 * 查询个人创作记录列表
	 */
	//@RequiresPermissions("meap:creation:list")
	@SysLog
	@ApiOperation(value = "查询个人创作记录列表")
	@PostMapping("/listUser")
	public PagingResult<CreationDetaileVo> listUser( String openId,String sortCreateTime){
		System.out.println("进入方法————————");
		startPage();
		List<CreationDetaileVo> list = creationService.selectListUser(openId,sortCreateTime);
		return getPagingResult(list);
	}


	/**
	 * 新增保存创作记录
	 */
	//@RequiresPermissions("meap:creation:add")
	@ApiOperation(value = "新增保存创作记录")
	@ApiImplicitParam(name = "creation", value = "新增保存创作记录",dataType = "Creation")
	@PostMapping("/add")
	public JsonResponse addSave(Creation creation)	{		
		return toAjax(creationService.insert(creation));
	}

	/**
	 * 修改保存创作记录
	 */
	//@RequiresPermissions("meap:creation:edit")
	@ApiOperation(value = "修改保存创作记录")
	@ApiImplicitParam(name = "creation", value = "修改保存创作记录",dataType = "Creation")
	@PutMapping("/edit")
	public JsonResponse editSave(Creation creation)	{		
		return toAjax(creationService.update(creation));
	}
	
	/**
	 * 删除创作记录
	 */
	//@RequiresPermissions("meap:creation:remove")
	@ApiOperation(value = "删除创作记录")
	@ApiImplicitParam(name = "ids", value = "根据id删除创作记录",dataType = "String")
	@DeleteMapping( "/remove")
	public JsonResponse remove(String ids)	{		
		return toAjax(creationService.deleteByIds(ids));
	}


	
}
